<?php

defined("_ARKN_EXEC") or exit("no no, mr. superman no here");
require_once ROOT_FOLDER . "/php/scripts/role_scripts/Roles.php";

if($_SESSION["auth"] == 0) {
	if(!isset($_GET["page"]))
		require "php/pages/login_page.php";
	else {
		$page = $_GET["page"];
		if($page == "run_login") {
			require "php/scripts/authentication/login_scr.php";
		} else
			require "page_not_found.html";
	}
} else {
	if(!isset($_GET["page"]))
		$page = "home";
	else
		$page = $_GET["page"];

	if($page == "home") {
		require "php/pages/home_page.php";
		exit;
	} else if($page == "run_logout") {
		require "php/scripts/authentication/logout_scr.php";
		exit;
	}

	$roleid = $_SESSION["roleid"];
	if($roleid == Roles::Secretary) {
		//---------------------------------------------------------------------------------------------
		// START SECRETARY PAGES
		// START STUDENT MANAGEMENT
		//---------------------------------------------------------------------------------------------
		
		/*
		 * studentlist - lists all students
		 */
		if($page == "studentlist")
			require "php/pages/secretary_pages/student_pages/studentlist_page.php";
		
		/*
		 * viewstudent - lists all relevant information for a specified student
		 */
		else if($page == "viewstudent")
			require "php/pages/secretary_pages/student_pages/viewstudent_page.php";
		
		/*
		 * addstudent - displays page from addstudent_page.php
		 * run_addstudent - runs addstudent_scr.php
		 */
		else if($page == "addstudent")
			require "php/pages/secretary_pages/student_pages/addstudent_page.php";
		else if($page == "run_addstudent")
			require "php/scripts/account_scripts/addaccount_scr.php";
		
		/*
		 * findstudent_edit - displays findstudent_page with $action set to edit
		 * editstudent - displays page from editstudent_page.php
		 * run_editstudent - runs editstudent_scr.php
		 */
		else if($page == "findstudent_edit") {
			$action = "edit";
			require "php/pages/secretary_pages/student_pages/findstudent_page.php";
		} else if($page == "editstudent")
			require "php/pages/secretary_pages/student_pages/editstudent_page.php";
		else if($page == "run_editstudent")
			require "php/scripts/account_scripts/editaccount_scr.php";
		
		/*
		 * findstudent_enroll - displays findstudent_page with $action set to enroll
		 * enrollstudent - displays page from enrollstudent_page.php
		 */		
		else if($page == "findstudent_enroll") {
			$action = "enroll";
			require "php/pages/secretary_pages/student_pages/findstudent_page.php";
		}
		
		//---------------------------------------------------------------------------------------------
		// END STUDENT MANAGEMENT 
		//---------------------------------------------------------------------------------------------
		
		//---------------------------------------------------------------------------------------------
		// START COURSE MANAGEMENT
		//---------------------------------------------------------------------------------------------
		
		/*
		 * courselist - lists all courses
		 */
		else if($page == "courselist")
			require "php/pages/secretary_pages/course_pages/courselist_page.php";
		
		/*
		 * addcourse - displays page from addcourse_page.php
		 * run_addcourse - runs addcourse_scr.php
		 */
		else if($page == "addcourse")
			require "php/pages/secretary_pages/course_pages/addcourse_page.php";
		else if($page == "run_addcourse")
			require "php/scripts/course_scripts/addcourse_scr.php";
		
		//---------------------------------------------------------------------------------------------
		// END COURSE MANAGEMENT 
		//---------------------------------------------------------------------------------------------
		
		//---------------------------------------------------------------------------------------------
		// END SECRETARY PAGES 
		//---------------------------------------------------------------------------------------------
		
		// Inexistent page
		else
			require "page_not_found.html";
	}
}
?>